package com.gouaixin.bee.beeframework2.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.gson.Gson;
import com.gouaixin.bee.beeframework2.R;
import com.gouaixin.bee.beeframework2.bean.Goods_id;
import com.gouaixin.bee.beeframework2.bean.Pay;
import com.gouaixin.bee.beeframework2.tool.PreferencesUtils;
import com.gouaixin.bee.beeframework2.tool.mLog;

/**
 * Created by Administrator on 2015/3/10.
 */
//我的Y币界面
public class B13_yBiActivity extends FragmentActivity {
    Context context=B13_yBiActivity.this;
    String titleName;

    LinearLayout yBi01Bt,yBi02Bt,yBi03Bt,yBi04Bt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.b13_ybi);

        cid= PreferencesUtils.getString(context, "cid");

        initView();


        
        initHead();
        initContent();

        setListener();

        //设置退款
//        initTuikuan();

    }

//    private void initTuikuan() {
//        final LinearLayout tuikuan= (LinearLayout) findViewById(R.id.tuikuan);
//        tuikuan.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                AbToastUtil.showToast(context,"亲，您还没有充值过哦！");
//            }
//        });
//
//        //未vip，显示
//       MemberModel.getUSER(context, new MemberModel.GetUserLister() {
//           @Override
//           public void onSuccess(USER user) {
//               long vipEndTime=user.getVipEndTime();
//               long currentTime=System.currentTimeMillis();
//               //如果是会员
//               if(currentTime<vipEndTime){
//                   tuikuan.setVisibility(View.GONE);
//               }
//               //不是会员
//               else{
//                   tuikuan.setVisibility(View.VISIBLE);
//               }
//           }
//
//           @Override
//           public void onFailure(int i, String s) {
//
//           }
//       });
//
//
//
//    }

    private String order_name="",order_price="";
    private int goods_id;//商品的唯一id
    Pay bean=new Pay();
    String cid="";
    Intent it;


    private void setListener() {
        yBi01Bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                MemberModel.ybiSuccess(context, YbiType.Type_100);
                order_name="购买1300Y币";
                order_price="100";

                bean.setAmount(order_price);
                bean.setCid(cid);
                bean.setTradeName(order_name);
                bean.setGoods_id(Goods_id.Ybi_100);

                it=new Intent(context,F1_PaySelectActivity.class);
                it.putExtra("pay",new Gson().toJson(bean));
                mLog.e("vip界面传出的pay=" + new Gson().toJson(bean));
                startActivity(it);
            }
        });

        yBi02Bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                MemberModel.ybiSuccess(context, YbiType.Type_50);
                order_name="购买600Y币";
                order_price="50";

                bean.setAmount(order_price);
                bean.setCid(cid);
                bean.setTradeName(order_name);
                bean.setGoods_id(Goods_id.Ybi_50);

                it=new Intent(context,F1_PaySelectActivity.class);
                it.putExtra("pay",new Gson().toJson(bean));
                mLog.e("vip界面传出的pay=" + new Gson().toJson(bean));
                startActivity(it);
            }
        });

        yBi03Bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                MemberModel.ybiSuccess(context, YbiType.Type_30);
                order_name="购买300Y币";
                order_price="30";

                bean.setAmount(order_price);
                bean.setCid(cid);
                bean.setTradeName(order_name);
                bean.setGoods_id(Goods_id.Ybi_30);

                it=new Intent(context,F1_PaySelectActivity.class);
                it.putExtra("pay",new Gson().toJson(bean));
                mLog.e("vip界面传出的pay=" + new Gson().toJson(bean));
                startActivity(it);
            }
        });
        yBi04Bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                MemberModel.ybiSuccess(context, YbiType.Type_10);
                order_name="购买80Y币";
                order_price="10";

                bean.setAmount(order_price);
                bean.setCid(cid);
                bean.setTradeName(order_name);
                bean.setGoods_id(Goods_id.Ybi_10);

                it=new Intent(context,F1_PaySelectActivity.class);
                it.putExtra("pay",new Gson().toJson(bean));
                mLog.e("vip界面传出的pay=" + new Gson().toJson(bean));
                startActivity(it);
            }
        });



    }

    private void initView() {
        yBi01Bt= (LinearLayout) findViewById(R.id.yBi01Bt);
        yBi02Bt= (LinearLayout) findViewById(R.id.yBi02Bt);
        yBi03Bt= (LinearLayout) findViewById(R.id.yBi03Bt);
        yBi04Bt= (LinearLayout) findViewById(R.id.yBi04Bt);

    }


    /***
     * 内容区域的监听
     */
    private void initContent() {




    }

    /***
     * 头部的监听
     */
    private void initHead() {
        //顶部
        ImageView back;//返回
        TextView title;//标题

        back= (ImageView) findViewById(R.id.back);
        title= (TextView) findViewById(R.id.title);



        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
